package com.sojson.util.security.shiro.config.init;

import org.springframework.boot.CommandLineRunner;

import com.sojson.util.SpringUtil;
import com.sojson.util.security.shiro.config.ConstantBean;
import com.sojson.util.security.shiro.config.shiro.ShiroConfig;

import lombok.extern.slf4j.Slf4j;

/**
 * 不固定的应用程序初始化类
 * 
 * @author liu
 * @Date 2020-06-23 09:42:11
 * @Description
 *
 */
@Slf4j
public class StaticBeanInit implements CommandLineRunner {

    @Override
    public void run(String... args) throws Exception {
        setBean();
    }

    /**
     * 给ConstantBean的属性赋值
     */
    public void setBean() {
        log.info("开始给ConstantBean的属性赋值!");

        ShiroConfig shiroConfig = SpringUtil.getBean("shiroConfig", ShiroConfig.class);

        ConstantBean.SHIRO_REALM = shiroConfig.customShiroRealm();
        ConstantBean.SECURITY_MANAGER = shiroConfig.customSecurityManager();

        log.info("给ConstantBean的属性赋值成功!");
    }

}